import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

/**
 * Created by 书强 on 2017/2/9.
 */
public class Ceshi {
    public static void main(String[] args) {

        List<Integer> list = new ArrayList<Integer>();

        for (int i = 0; i < 6; i++) {
            int num = (int) ((Math.random()) * 40);
            list.add(num);
        }
        Collections.sort(list, new NumComparator());

        list.add((int) ((Math.random()) * 20));

        System.out.println(list);
    }

    static class NumComparator implements Comparator {
        public int compare(Object num1, Object num2) {
            return new Integer((int) num1).compareTo(new Integer((int) num2));
        }
    }
}
